import multiprocessing
import time

def task(name: str, count: int):
    print(f"{name} - step 1\n", end="")
    result = 0
    for i in range(count):
        result += i + 1
    time.sleep(5)
    print(f"{name}- end with {result}")
    
def start_process1():
    name = "p1"
    count = 100
    process = multiprocessing.Process(target=task, args=(name, count))
    process.start()

    process.join()
    print("main process over")
    
def statr_process2():
    args_list = [("a", 100), ("b", 99), ("c", 98)]
    processes = [
        multiprocessing.Process(target=task, args=(name, count)) for name, count in args_list
    ]
    
    for p in processes:
        p.start()
    
    for p in processes:
        p.join()
    
# 创建进程
if __name__ == "__main__":
    # start_process1()
    statr_process2()